<?php
$this->title = 'Ajouter un resultat';
$this->headTitle($this->title);
echo $this->partial('partial/grandprix.phtml', array('grandprix'=>$this->grandprix, 'id'=>$this->gp->getGpNum()));
if(!is_null($this->gp))
{
	if($this->message)
	{
		echo $this->message;
	}
	echo "<h1>".$this->gp->getGpNom()."<br/><span>(".date('d/m/Y',strtotime($this->gp->getGpDate())).")</span></h1>";
	echo "<table style='margin:auto;' class='tabresultat'><tr><th>Place</th><th>Pilote</th><th>Temps</th><th>Nb de points</th></tr>";
	$i=1;
	if(count($this->gp->getCourse())!=0)
	{
		foreach($this->gp->getCourse() as $course)
		{
			$points=0;
			if(count($this->points)>=$i)
			{
				$points=$this->points[$i-1]->getPtNbPointsPlace();
			}
			echo "<tr><td>$i</td><td>".$course->getPilote()->getPilNom()."</td><td>".$course->getTempsCourse()."</td><td>".$points."</td></tr>";
			$i++;
		}
	}
	$this->form->setAction($this->url());
	$this->form->getElement('position')->setValue('#');
	echo $this->form;
	echo "</table>";
}
else
{
	//throw new Zend_Controller_Action_Exception('Page not found.',404);
	echo $this->partial('partial/errorbox.phtml',array('message' => "Le Grand-Prix est introuvable."));
}
